package com.example.xxcjgl.data.models

// Resource.kt
sealed class Resource<out T> {
    object Initial : Resource<Nothing>()

    class Loading<T> : Resource<T>()

    data class Success<out T>(
        val data: T
    ) : Resource<T>()

    data class Error<out T>(
        val message: String,
        val data: T? = null
    ) : Resource<T>()

    companion object {
        fun <T> initial(): Resource<T> = Initial

        fun <T> loading(): Resource<T> = Loading()

        fun <T> success(data: T): Resource<T> = Success(data)

        fun <T> error(message: String, data: T? = null): Resource<T> = Error(message, data)
    }
}